#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
typedef struct node{
	int data;
	struct node *next;
};
void create(node *head,int size){
	node *t=head;
	for(int i=0;i<size;i++){
		node *newNode=(node *)malloc(sizeof(node));
		newNode->next=NULL;
		scanf("%d",&newNode->data);
		t->next=newNode;
		t=newNode;
	}
	
}
void delet(node *pHead,int pos){
	if(pHead != NULL){
		node *p1=pHead;
		node *p2=pHead->next;
		
		while(p2->data != pos){
			p2=p2->next;
			p1=p1->next;
		}
		
		p1->next=p2->next;	
		free(p2);
		p2->next=NULL;
	}	
}

    void insert(node *pos,int data){
	 	node *newNode=(node *)malloc(sizeof(node));
  	 	newNode->data=pos->data;
	
		newNode->next=pos->next;
		pos->next=newNode;
	
		pos->data=data;
}


void trave(node *head){
	node *t=head->next;
	while(t != NULL){
		printf("%d ",t->data);
		t=t->next;
	}	
}
int main()
{
	node *newNode=(node *)malloc(sizeof(node));
	node *newNode1=(node *)malloc(sizeof(node));

	create(newNode,5);
	trave(newNode);
	printf("\n");
	delet(newNode,3);
	trave(newNode);
	printf("\n");
	insert(newNode1,3);
	trave(newNode);
	
	
	return 0;
}
